import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';


export default defineNuxtConfig({
  devtools: { enabled: true },
  ssr: true,

  devServer: {
    port: 9001
  },

  components: true,



  // 软件配置
  app: {
    head: {

      // SEO优化
      title: "Lin | Store",
      charset: 'utf-8',
      meta: [
        { 
          name: "description",
          content: "store, width=device-width, initial-scale=0, user-scalable=yes,shrink-to-fit=no"
        },

        { 
          name: "keyword",
          content: "Lin | Store, width=device-width, initial-scale=0, user-scalable=yes,shrink-to-fit=no" 
        }
      ],

      // 网页图标
      link: [
        { rel: "icon", type: "image/x-icon", href: "logo.svg" }
      ]

    }
  },


  modules: [
    '@element-plus/nuxt',
    'nuxt-icons',
    '@pinia/nuxt',
    '@hypernym/nuxt-gsap'
  ],

  gsap: {
    // Module options
    composables: true,
    
    extraPlugins: {
      scrollTrigger: true,
    },
  },

  css: [
    '@/assets/main.css',
    'element-plus/dist/index.css',
  ],

  elementPlus: { /** Options */
    importStyle: "css",
    themes: ['dark'],
    icon: "ElIcon",
    injectionID: { prefix: 1024, current: 0 }
  },



  build: {
    transpile:
      process.env.NODE_ENV === 'production'
        ? [
            'naive-ui',
            'vueuc',
            '@css-render/vue3-ssr',
            '@juggle/resize-observer',
          ]
        : ['@juggle/resize-observer'],

  },
  vite: {
    optimizeDeps: {
      include:
        process.env.NODE_ENV === 'development'
          ? [
              'naive-ui',
              'vueuc',
              'date-fns-tz/formatInTimeZone',
              '@css-render/vue3-ssr',
              '@juggle/resize-observer',
            ]
          : ['@juggle/resize-observer']
    },

    plugins: [
      AutoImport({
        imports: [
          {
            'naive-ui': ['useDialog', 'useMessage', 'useNotification', 'useLoadingBar'],
          },
        ],
      }),

      Components({
        resolvers: [NaiveUiResolver()],
      }),

      {src: '@/plugins/globalprops.js', mode: 'client'},
      {src: '@/plugins/element-icon.ts', mode: 'client'},
      {src: '@/plugins/globalloading.js', mode: 'client'},
      {src: '@/plugins/naive-ui.ts', mode: 'client'},
      {src: '@/utils/login.js', mode: 'client'}
    ]
  },



})
